// 引入二次封装axios
import request from "@/utils/request";
import type { DoctorInfoData, UserResponseData, DoctorResponseData, HospitalWordData, HospitalDetail, DeparmentResponseData, LoginData, UserLoginResponseData, WXLoginResponseData } from './type';

// 枚举请求地址
enum API {
    // 获取医院详情
    HOSPITALDETAIL_URL = '/hosp/hospital/',
    // 获取某一个医院的科室的数据
    HOSPITALDEPARMENT_URL = '/hosp/hospital/department/',
    // 获取验证码
    GETUSERCODE_URL = '/sms/send/',
    // 用户登录
    USERLOGIN_URL = '/user/login',
    // 获取微信扫码登录需要参数
    WXLOGIN_URL = '/user/weixin/getLoginParam/',
    // 获取某一个医院的某一个科室预约挂号数据
    HOSPITALWORK_URL = '/hosp/hospital/auth/getBookingScheduleRule/',
    // 获取医院某一个科室某一天相应医生排班的数据
    HOSPITALDOCTOR_URL = '/hosp/hospital/auth/findScheduleList/',
    // 获取某一个账号下就诊人的信息
    GETUSER_URL = '/user/patient/auth/findAll',
    // 获取挂号医生的信息
    GETDOCTOR_URL = '/hosp/hospital/getSchedule/'
};

// 获取医院详情的接口
export const reqHospitalDetail = (hoscode: string) => {
    return request<any, HospitalDetail>({
        url: API.HOSPITALDETAIL_URL + hoscode,
        method: 'get'
    })
};

// 获取医院科室的接口
export const reqHospitalDeparment = (hoscode: string) => {
    return request<any, DeparmentResponseData>({
        url: API.HOSPITALDEPARMENT_URL + hoscode,
        method: 'get'
    })
};

// 获取验证码接口
export const reqCode = (phone: string) => {
    return request<any, any>({
        url: API.GETUSERCODE_URL + phone,
        method: 'get'
    })
};

// 用户登录接口
export const reqUserLogin = (data: LoginData) => {
    return request<any, UserLoginResponseData>({
        url: API.USERLOGIN_URL,
        method: 'post',
        data
    })
};

//获取微信扫码登录生成二维码需要参数接口
export const reqWxLogin = (wxRedirectUri: string) => {
    return request<any, WXLoginResponseData>({
        url: API.WXLOGIN_URL + `?wxRedirectUri=${wxRedirectUri}`,
        method: 'get'
    })
};

// 获取某一个医院的某一个科室预约挂号数据接口
export const reqHospitalWork = (page: number, limit: number, hoscode: string, depcode: string) => {
    return request<any, HospitalWordData>({
        url: API.HOSPITALWORK_URL + `${page}/${limit}/${hoscode}/${depcode}`,
        method: 'get'
    })
};

// 获取医生排班的数据
export const reqHospitalDoctor = (hoscode: string, depcode: string, workDate: string) => {
    return request<any, DoctorResponseData>({
        url: API.HOSPITALDOCTOR_URL + `${hoscode}/${depcode}/${workDate}`,
        method: 'get'
    })
};

// 获取某一个账号下就诊人信息
export const reqGetUser = () => {
    return request<any, UserResponseData>({
        url: API.GETUSER_URL,
        method: 'get'
    })
};

// 获取挂号医生的信息
export const reqDoctorInfo = (scheduleId: string) => {
    return request<any, DoctorInfoData>({
        url: API.GETDOCTOR_URL + scheduleId,
        method: 'get'
    })
};


